import {defHttp} from '/@/utils/http/axios';
import {Modal} from 'ant-design-vue';

enum Api {
  page = "/system-service/tenantPackage/page",
  list = "/system-service/tenantPackage/list",
  save = "/system-service/tenantPackage/save",
  edit = "/system-service/tenantPackage/update",
  delete = "/system-service/tenantPackage/delete",
  deleteBatch = "/system-service/tenantPackage/deleteBatch",
}

/**
 * 分页
 * @param params
 */
export const pageTenantPackage = (params) => {
  return defHttp.get({url: Api.page, params});
}

export const listTenantPackage = (params) => {
  return defHttp.get({url: Api.list, params});
}


/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdateTenantPackage = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}

/**
 * 删除
 * @param params
 */
export const deleteTenantPackage = (params, handleSuccess) => {
  return defHttp.delete({url: Api.delete, data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

/**
 * 批量删除
 * @param params
 */
export const batchDeleteTenantPackage = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
